<?php

class Application_Model_Screenshot extends Zend_Db_Table_Abstract
{
    protected $_name = "kp_screenshot"; //Ten bang
    protected $_primary = "scr_id"; //Khoa chinh
    protected $db;
    //Cac truong du lieu
    var $scr_id;
    var $app_id;
    var $scr_link;
    
    //Ham khoi tao
    public function __construct(){
        $this->db = Zend_Registry::get('db');
    }
    
    //Get all user
    public function getAll($status=-1){
        $query = $this->db->select();
        $query->from($this->_name);
        if($status!=-1)$query->where('scr_status = ?',$status);
        $query->order(array('scr_link'));
        return $this->db->fetchAll($query);
    }
    public function getByAppID($id){
        $query = $this->db->select();
        $query->from($this->_name);
        $query->where('app_id = ?',$id);
        //$query->order(array('scr_link'));
        return $this->db->fetchAll($query);
    }
    //Them mới user
    public function insertNew(){
        $data = array(
                'scr_link' => $this->scr_link,
                'app_id'=>$this->app_id,
        );
        //var_dump($data); die;
        return $this->db->insert($this->_name,$data);
    }

}

